'''
Created on 19/04/2010

@author: Mar
'''

from CPU import *

from planifCortoPlazo_FF import *
from planifCortoPlazo_Priority import *


from ThreadCPU import *
from ThreadCPU import *
from CPU import *
from multiprocessing import Queue
import time

from ManagerResource import *

class OS:
        
    def __init__(self, scheduler, resourceManager,aCPUmanager, outputQueue): 
        self.scheduler = scheduler
        self.newQueue = Queue()
        self.readyQueue = self.scheduler.readyQueue
        self.outputQueue = outputQueue
        self.resourceManager = resourceManager
        self.cpuManager = aCPUmanager
        
    def setReadyQueue(self,aQueue):
        self.readyQueue= aQueue
    
    def addProgram(self,aProgram):
        pcb = aProgram.toPCB()
        self.newQueue.put(pcb)
        x = self.newQueue.get()
        x.toReady()
        self.scheduler.addPCB(x)
        
        
    def startUP(self):
        self.cpuManager.startUp()
        self.resourceManager.startUp()

        
    def shutDown(self):
        print("FIN") 
        exit()